<template>
  <div>
    <body>
      <h1>图书管理后台登录</h1>
      <div class="w3ls-login box">
        <form>
          <div class="agile-field-txt">
            <input
              type="text"
              v-model="ruleForm.accountName"
              placeholder="用户名"
            />
          </div>
          <div class="agile-field-txt">
            <input
              type="password"
              v-model="ruleForm.accountPass"
              placeholder="密码"
              id="myInput"
            />
          </div>
          <div class="w3ls-bot">
            <input @click="login" type="button" value="登  录" />
          </div>
        </form>
      </div>
    </body>
  </div>
</template>
<script>
export default {
  name: "BackLogin",
  data() {
    return {
      ruleForm: {
        accountPass: "",
        accountName: "",
      }
    };
  },
  methods: {
    login() {
      //登录操作
      this.$http.post("/account/login", this.ruleForm).then(resp => {
        if (resp.data.code == 200) {
          alert(resp.data.message);
          this.$router.push("/main");
        } else {
          //登录失败
          alert(resp.data.message);
          this.ruleForm.accountName = "";
          this.ruleForm.accountPass = "";
        }
      });
    }
  }
};
</script>

<style scoped>
@import "../../assets/css/backLogin.css" ;
</style>

<style></style>
